package com.binance.assetservice.api;

import java.math.BigDecimal;

import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import com.binance.assetservice.annotation.Source;
import com.binance.assetservice.vo.request.AssetTransferRequest;
import com.binance.assetservice.vo.request.AsssetBalanceRequest;
import com.binance.assetservice.vo.request.DeductionFeeRequest;
import com.binance.assetservice.vo.request.DribbletAssetToBNBRequest;
import com.binance.assetservice.vo.request.FreezeAssetRequest;
import com.binance.assetservice.vo.request.GetOneUserAssetRequest;
import com.binance.assetservice.vo.request.GetPrivateUserAssetRequest;
import com.binance.assetservice.vo.request.GetUserAssetRequest;
import com.binance.assetservice.vo.request.SyncBalanceRequest;
import com.binance.assetservice.vo.request.UserAssetTimeQuery;
import com.binance.assetservice.vo.request.UserAssetTransferBtcRequest;
import com.binance.assetservice.vo.request.UserAssetTransferDribbletBtcRequest;
import com.binance.assetservice.vo.request.UserNegativeAssetRequest;
import com.binance.assetservice.vo.request.WithdrawAssetFailRequest;
import com.binance.assetservice.vo.request.WithdrawAssetRequest;
import com.binance.assetservice.vo.request.WithdrawAssetSuccessRequest;
import com.binance.assetservice.vo.response.DribbletAssetToBNBResponse;
import com.binance.assetservice.vo.response.PagingResult;
import com.binance.assetservice.vo.response.UserAssetItemResponse;
import com.binance.assetservice.vo.response.UserAssetResponse;
import com.binance.assetservice.vo.response.UserAssetTransferBtcResponse;
import com.binance.assetservice.vo.response.UserAssetTransferDribbletBtcResponse;
import com.binance.master.configs.FeignConfig;
import com.binance.master.constant.Constant;
import com.binance.master.models.APIRequest;
import com.binance.master.models.APIResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api
@FeignClient(name = Constant.ASSET_SERVICE, configuration = FeignConfig.class)
public interface IUserAssetApi {
	
    @ApiOperation(value = "获取资产为0的asset")
    @PostMapping(value = "/private/queryNegativeAssetByUserId", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    APIResponse<Integer> queryNegativeAssetByUserId(@RequestBody APIRequest<UserNegativeAssetRequest> request);

    // --------------------------------------------------------------------------------------------------------
    @ApiOperation("资产转移接口，从一个用户转移到另一个用户。从from用户账户减去指定的金额，在to用户账户增加指定的金额")
    @PostMapping(value = "/asset-service/private/assetTransfer", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public APIResponse<Void> assetTransfer(@RequestBody APIRequest<AssetTransferRequest> request) throws Exception;
    // --------------------------------------------------------------------------------------------------------


    @ApiOperation("获取指定用户的所有资产（或指定的资产）。返回的UserAssetResponse中可能包含多个UserAsset")
    @PostMapping(value = "/private/userAsset", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @Source(value = "", originalUrl = "/private/userAsset,/mgmt/userAsset")
    public APIResponse<UserAssetResponse> getPrivateUserAsset(
            @RequestBody APIRequest<GetPrivateUserAssetRequest> request) throws Exception;

    @ApiOperation("获取（指定的某些用户）的指定的资产信息。如果分页信息不指定则不会分页，即返回全量数据。")
    @PostMapping(value = "/private/getUserAsset", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public APIResponse<PagingResult<UserAssetItemResponse>> getUserAsset(
            @RequestBody APIRequest<GetUserAssetRequest> request) throws Exception;

    @ApiOperation("获取指定用户的指定的资产。返回的UserAssetResponse中最多包含一个UserAsset")
    @PostMapping(value = "/userasset/oneUserAsset", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public APIResponse<UserAssetItemResponse> getOneUserAsset(@RequestBody APIRequest<GetOneUserAssetRequest> request)
            throws Exception;

    // @ApiOperation("返回的UserAssetResponse中最多包含一个UserAsset")
    // @PostMapping(value = "/userasset/processTradeForBackfillTrades", produces =
    // MediaType.APPLICATION_JSON_UTF8_VALUE)
    // public APIResponse<Void> processTradeForBackfillTrades(
    // @RequestBody APIRequest<ProcessTradeForBackfillTradesRequest> request) throws Exception;

    @ApiOperation("用户资产提现申请")
    @PostMapping(value = "/mgmt/user/asset/withdraw", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public APIResponse<Void> withdrawAsset(@RequestBody APIRequest<WithdrawAssetRequest> request) throws Exception;

    @ApiOperation("用户资产提货成功 更新用户withdrawing和cost，百分比更新cost")
    @PostMapping(value = "/mgmt/user/asset/withdrawSuccess", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public APIResponse<Void> withdrawAssetSuccess(@RequestBody APIRequest<WithdrawAssetSuccessRequest> request)
            throws Exception;

    @ApiOperation("用户资产提货失败，退回资产到free 更新free和withdrawing")
    @PostMapping(value = "/mgmt/user/asset/withdrawFail", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public APIResponse<Void> withdrawassetFail(@RequestBody APIRequest<WithdrawAssetFailRequest> request)
            throws Exception;

    @PostMapping(value = "/mgmt/user/asset/balance", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public APIResponse<Void> asssetBalance(@RequestBody APIRequest<AsssetBalanceRequest> request) throws Exception;

    @PostMapping(value = "/mgmt/user/asset/freeze", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public APIResponse<Void> freezeAsset(@RequestBody APIRequest<FreezeAssetRequest> request) throws Exception;

    @PostMapping(value = "/mgmt/syncBalance", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public APIResponse<Void> syncBalance(@RequestBody APIRequest<SyncBalanceRequest> request) throws Exception;


    @ApiOperation("扣除手续费")
    @PostMapping(value = "/mgmt/info/deductionFee", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public APIResponse<Void> deductionFee(@RequestBody APIRequest<DeductionFeeRequest> request) throws Exception;

    @ApiOperation(value = "资产BTC估值")
    @PostMapping(value = "/private/userAssetTransferBtc", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @Source(value = "exchange-web", originalUrl = "/private/userAssetTransferBtc,/mgmt/userAssetTransferBtc")
    public APIResponse<UserAssetTransferBtcResponse> userAssetTransferBtc(
            @RequestBody APIRequest<UserAssetTransferBtcRequest> request) throws Exception;

    @ApiOperation(value = "小额资产转换为BNB")
    @PostMapping(value = "/private/dribbletAssetToBNB", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public APIResponse<DribbletAssetToBNBResponse> dribbletAssetToBNB(
            @RequestBody APIRequest<DribbletAssetToBNBRequest> request) throws Exception;

    @ApiOperation(value = "获取小额资产：总额小于0.001BTC的资产")
    @PostMapping(value = "/private/userAssetTransferDribbletBtc", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public APIResponse<UserAssetTransferDribbletBtcResponse> userAssetTransferDribbletBtc(
            @RequestBody APIRequest<UserAssetTransferDribbletBtcRequest> request) throws Exception;

    @ApiOperation(value = "查询指定时间点的持仓")
    @PostMapping(value = "/private/queryAssetAmountByTime", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    APIResponse<BigDecimal> queryAssetAmountByTime(@RequestBody APIRequest<UserAssetTimeQuery> request);


}
